<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
	<title>广告列表</title>
	<script type='text/javascript' src='__ROOT__/Data/Org/Jquery/jquery-1.8.2.min.js'></script>
	<link href='__ROOT__/Data/Org/hdjs/css/hdjs.css' rel='stylesheet' media='screen'>
	<script type='text/javascript' src='__ROOT__/Data/Org/hdjs/js/hdjs.js'></script>
	<script type='text/javascript' src='__ROOT__/Data/Org/hdjs/js/slide.js'></script>
	<script type='text/javascript' src='__ROOT__/Data/Org/hdjs/org/cal/lhgcalendar.min.js'></script>
	<script type='text/javascript'>
		ACTION='__URL__'; //当前模块(控制器)
		ROOT='__ROOT__'; //当前项目根路径
		PUBLIC= '__PUBLIC__';//当前定义的Public目录
	</script>
	<link rel="stylesheet" type="text/css" href="__PUBLIC__/Css/mod.base.css" />
	<style type="text/css">
		.search{
			border: 1px solid #FFBE7A;
			background: none repeat scroll 0 0 #FFFCED;
			line-height: 20px;
			padding: 8px 10px;
		}
		.red{
			color:red;
		}
	</style>
</head>
<body>
	<div class="wrap">

		<form action="<?php echo U('Ad/index');?>" class="hd-form" method="get" >
			
			<input type="hidden" name="sta" value="<?php echo ($_GET['sta']); ?>" />
			<div class="search">

				<!-- 添加时间：
				<input id="begin_time" placeholder="开始时间" readonly="readonly" class="w80" type="text" value="<?php if(isset($_GET["search_begin_time"])): echo ($_GET['search_begin_time']); endif; ?>" name="search_begin_time">
				<script>
					$('#begin_time').calendar({
						format : 'yyyy-MM-dd'
					});
				</script>
				-
				<input id="end_time" placeholder="结束时间" readonly="readonly" class="w80" type="text" value="<?php if(isset($_GET["search_end_time"])): echo ($_GET['search_end_time']); endif; ?>" name="search_end_time">
				<script>
					$('#end_time').calendar({
						format : 'yyyy-MM-dd'
					});
				</script>
				&nbsp;&nbsp;&nbsp; -->
				<!-- <select name="search_type" class="w100">
					<option value="1" <?php if(isset($_GET['search_type']) && $_GET['search_type'] == 1): ?>selected='selected'<?php endif; ?>>名称</option>
					<option value="2" <?php if(isset($_GET['search_type']) && $_GET['search_type'] == 2): ?>selected='selected'<?php endif; ?>>用户名</option>
					<option value="3" <?php if(isset($_GET['search_type']) && $_GET['search_type'] == 3): ?>selected='selected'<?php endif; ?>>用户uid</option>
				</select>&nbsp;&nbsp;&nbsp; -->
				<select name="psid" class="w100">
					<option value="0">所有位置</option>
					<?php if(is_array($position)): foreach($position as $key=>$v): ?><option value="<?php echo ($v["psid"]); ?>" <?php if(isset($_GET['psid']) && $_GET['psid'] == $v['psid']): ?>selected='selected'<?php endif; ?>><?php echo ($v["position_name"]); ?></option><?php endforeach; endif; ?>
				</select>&nbsp;&nbsp;&nbsp;
				关键字：
				<input class="w200" type="text" placeholder="请输入关键字..." value="<?php if(isset($_GET["search_keyword"])): echo ($_GET['search_keyword']); endif; ?>" name="search_keyword">

				
				<button class="hd-cancel" type="submit">
					搜索
				</button>

				<button class="hd-cancel" type="button" onclick="location.href='<?php echo U('Ad/index');?>'">
					查看所有广告
				</button>
			</div>
		</form>
		<form action="<?php echo U('Ad/update');?>" method="post" id='list' class='hd-form'>
				<div class="menu_list">
					<ul>
						<li>
							<a href="<?php echo U('Ad/index');?>" <?php if($_GET["sta"] == 2): ?>class="action"<?php endif; ?>>
								广告列表
							</a>
						</li>
						<li>
							<a href="<?php echo U('Ad/index',array('sta'=>1));?>" <?php if($_GET["sta"] == 1): ?>class="action"<?php endif; ?>>
								未审核
							</a>
						</li>
						<li>
							<a href="<?php echo U('Ad/add');?>">
								添加
							</a>
						</li>
					</ul>
				</div>
				<table class="table2">
						<thead>
						<tr>
							<td class="w30">
							<input type="checkbox" class="select_all"/>
							</td>
							<td class="w30">AID</td>
							<td class="w30">PSID</td>
							<td class="w150">位置</td>
							<td class="w50">排序</td>
							<td>名称</td>
							<td>图片</td>
							<td class="w80">状态</td>
							<td class="w80">作者</td>
							<td class="w100">添加时间</td>
							<td class="w180">操作</td>
						</tr>
						</thead>
						<?php if($data): if(is_array($data)): foreach($data as $key=>$v): ?><tr>
							<td>
							<input type="checkbox" name="aid[<?php echo ($v["aid"]); ?>]" value="<?php echo ($v["aid"]); ?>"/>
							</td>
							<td><?php echo ($v["aid"]); ?></td>
							<td><?php echo ($v["psid"]); ?></td>
							<td><?php echo ($v["position_name"]); ?></td>
							<td>
							<input type="text" class="w30" value="<?php echo ($v["sort"]); ?>" name="list_order[<?php echo ($v["aid"]); ?>]"/>
							</td>
							<td><?php echo ($v["name"]); ?></td>
							<td><img src="<?php echo ($v["pic"]); ?>" alt=""  width="100" height='30' /></td>
							<td><?php echo ($v["verifystate"]); ?></td>
							<td><?php echo ($v["username"]); ?></td>
							<td><?php echo ($v["addtime"]); ?></td>
							<td>

							<a href="<?php echo U('Ad/edit',array('aid'=>$v['aid']));?>">
								修改
							</a>
							<span class="line">|</span>
							<a href="javascript:var del='<?php echo U('Ad/del',array('aid'=>$v['aid'],'psid'=>$v['position_psid']));?>';hd_confirm('确认删除吗？',function(){location.href=del})">
								删除
							</a></td>
						</tr><?php endforeach; endif; ?>
						<tr><td colspan="11" class="page"><?php echo ($page); ?></td></tr>
						<?php else: ?>
						<tr><td colspan="11">没有找到符合的记录</td></tr><?php endif; ?>

					</table>
				<div class="h60"></div>
		</form>
	</div>

	<div class="position-bottom">
		<input type="button" class="hd-cancel" onclick="select_all(1)" value='全选'/>
		<input type="button" class="hd-cancel" onclick="select_all(0)" value='反选'/>
		<input type="button" class="hd-cancel" onclick="update(1)" value="更改排序"  />
		<input class="hd-cancel" type="button" value="审核" onclick="update(2)" >
		<input class="hd-cancel" type="button" value="取消审核" onclick="update(3)" >
		<input class="hd-cancel" type="button" value="删除" onclick="update(4)" >
	</div>
<script>
//更新
function update(type) {
    //栏目检测
    var html;
    switch(parseInt(type))
	{
		case 1:
		type='排序';
		html='<input type="hidden" name="order" />';
		break;
		case 2:type='审核';
		html='<input type="hidden" name="check" />';
		break;
		case 3:type='取消审核';
		html='<input type="hidden" name="cancel_check" />';
		break;
		case 4:type='删除';
		html='<input type="hidden" name="del_check" />';
		break;
	}
    if ($("input[type='checkbox']:checked").length == 0) 
    {
        alert('没有信息用于'+type);
        return false;
    }
    $('#list').append(html);
  	$('#list').submit();
}
//点击input表单实现 全选或反选
$(function () {
    //全选
    $("input.select_all").click(function () {
        $("[type='checkbox']").attr("checked",$(this).attr('checked')=='checked');
    })
})
//全选复选框
function select_all(state){
	if(state==1){
		$("[type='checkbox']").attr("checked",state);
	}else{
		$("[type='checkbox']").attr("checked",function(){return !$(this).attr('checked')});
	}
}

</script>
</body>
</html>